
class MyThread extends Thread{
    public void run() {
        System.out.println("hehe");
    }
}

class MyRunnable implements Runnable{
    public void run() {
        System.out.println("haha");
    }
}
public class TherdDeom {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread( () -> {
            System.out.println("hello t");
        });
        t.start();
        t.join();
        System.out.println("hello main");
    }
    public static void main3(String[] args) throws InterruptedException {
        Thread t = new Thread( () -> {
            while (!Thread.currentThread().isInterrupted()) {
                System.out.println("hello t");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
        t.start();
        Thread.sleep(5000);
        t.interrupt();
    }
    public static void main2(String[] args) {
        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("hello t");
            }
        });
        t.start();
    }
    public static void main1(String[] args) {
        Thread t = new Thread() {
            public void run(){
                System.out.println("hello t");
            }
        };
        t.start();
    }
}
